package cn.kongwg.yygh.common.utils;

import cn.kongwg.yygh.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取当前用户的信息工具类
 *
 * @author kongwg
 * @create 2021-04-18 10:30
 */
public class AuthContextHolder {


    /**
     * 获取用户的id
     * @param request
     * @return
     */
    public static Long getUserInfoId(HttpServletRequest request) {

        String token = request.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }


    public static String getUserInfoName(HttpServletRequest request){
        String token = request.getHeader("token");
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}
